package com.taxshare.seller.controller;

import cn.hutool.core.collection.CollUtil;
import com.taxshare.pvalidate.ParamValid;
import com.taxshare.response.beans.Response;
import com.taxshare.seller.service.CarCategoryService;
import com.taxshare.seller.view.dto.CarCategoryDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @author cxl
 * @date 2021/8/19 13:14
 */
@RestController
@RequestMapping("/carCategory")
@Api(tags = "车辆种类信息")
public class CarCategoryController {

    @Autowired
    CarCategoryService carCategoryService;

    @PostMapping("/add")
    @ApiOperation(value = "车辆种类信息新增", notes = "车辆种类信息")
    @ParamValid
    public Response addCarCategory(@RequestBody @Valid CarCategoryDTO carCategoryDTO) {
        return carCategoryService.addCarCategory(carCategoryDTO);
    }

    @GetMapping("/remove")
    @ApiOperation(value = "车辆种类信息删除", notes = "车辆种类信息")
    public Response removeCarCategory(String[] ids) {

        return carCategoryService.removeCarCategory(CollUtil.toList(ids));
    }

    @PostMapping("/edit")
    @ApiOperation(value = "车辆种类信息编辑", notes = "车辆种类信息")
    public Response editCarCategory(@RequestBody CarCategoryDTO carCategoryDTO) {
        return carCategoryService.editCarCategory(carCategoryDTO);
    }

    @GetMapping("/list")
    @ApiOperation(value = "车辆种类信息查询", notes = "车辆种类信息")
    public Response listCarCategoryByKeyword(String keyword) {
        return carCategoryService.listCarCategoryByKeyword(keyword);
    }

}
